package com.stx.demo1011;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

public class 反序列化 {
    public static void main(String[] args) {
//        User user = new User("xiaoming", 18, "nan");
        try {
            //打开序列化文件
            FileInputStream file=new FileInputStream("D:\\git_homework\\4-6-parts\\task\\README.md");
            //反序列化
            ObjectInputStream ois=new ObjectInputStream(file);
            //读取反序列化文件
            User user= (User)ois.readObject();//强制转化
            System.out.println(user);

//        } catch (FileNotFoundException e) {
//            throw new RuntimeException(e);
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        } catch (ClassNotFoundException e) {
//            throw new RuntimeException(e);
//        }
        } catch (ClassNotFoundException | IOException e) {
            throw new RuntimeException(e);
        }
    }
}
